package com.spring.sunflower.conversation;

import android.content.Intent;
import android.view.View;

import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.spring.sunflower.R;
import com.spring.sunflower.base.BaseActivity;
import com.spring.sunflower.bean.AccountBean;
import com.spring.sunflower.bean.AnchorDetailBean;
import com.spring.sunflower.bean.STSCertBean;
import com.tencent.imsdk.v2.V2TIMMessage;
//import com.tencent.qcloud.tim.uikit.component.TitleBarLayout;
//import com.tencent.qcloud.tim.uikit.modules.chat.ChatLayout;
//import com.tencent.qcloud.tim.uikit.modules.chat.base.ChatInfo;
//import com.tencent.qcloud.tim.uikit.modules.chat.layout.input.InputLayout;
//import com.tencent.qcloud.tim.uikit.modules.message.CustomMessageBean;
//import com.tencent.qcloud.tim.uikit.modules.message.MessageInfoUtil;


/**
 * Created by Kevin on 2021/6/5<br/>
 * <p>
 * Describe:<br/>
 */
public class ChatXActivity extends BaseActivity<ChatPresenter> implements ConversationView, View.OnClickListener {
    private SmartRefreshLayout refreshLayout;
//    private ChatLayout mChatLayout;
//    private ChatInfo mChatInfo;
//    private TitleBarLayout mTitleBar;
//    private InputLayout mInputLayout;
//    private String mUserId;
//    private String nickName;
//    private String avatar;
//    private String keyID = "", keySecret = "", securityToken = "";
//    private AliUploadUtils aliUploadUtils;
//    private Gson gson;
//    private InputLayout.MessageHandler messageHandler;
//    private CustomMessageBean mCustomMessageBean;

//    private CustomMessageBean getCustomMessageBean() {
//        CustomMessageBean customMessageBean1 = new CustomMessageBean();
//        CustomMessageBean.DataBean dataBean = new CustomMessageBean.DataBean();
//        CustomMessageBean.DataBean.UserBean userBean1 = new CustomMessageBean.DataBean.UserBean();
//        userBean1.memberId = this.mChatInfo.getId();
//        userBean1.nickname = this.mChatInfo.getChatName();
//        userBean1.photo = this.mChatInfo.getPhoto();
//        CustomMessageBean.DataBean.UserBean userBean2 = new CustomMessageBean.DataBean.UserBean();
//        userBean2.memberId = this.mUserId;
//        userBean2.nickname = nickName;
//        userBean2.photo = avatar;
//        userBean2.selfSend = "1";
//        dataBean.fromUser = userBean2;
//        dataBean.toUser = userBean1;
//        customMessageBean1.data = dataBean;
//        return customMessageBean1;
//    }
    @Override
    public void initView() {
        Intent intent = getIntent();
//        mChatInfo = (ChatInfo) intent.getSerializableExtra(Constant.CHAT_INFO);
//        mUserId = getField(Constant.KEY_USERID, "");
//        nickName = getField(Constant.KEY_NICKNAME, "");
//        avatar = getField(Constant.KEY_PHOTO, "");
//        mPresenter.getSTSCert();
//        gson = new Gson();
//        mChatLayout = findViewById(R.id.chat_layout);
//        //单聊组件的默认UI和交互初始化
//        mChatLayout.initDefault();
//        mChatLayout.setChatInfo(mChatInfo);
//        mTitleBar = mChatLayout.getTitleBar();
//        mTitleBar.getMiddleTitle().setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
//        mTitleBar.setOnLeftClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                finish();
//            }
//        });
//        ImageView iv = mTitleBar.getRightGroup().findViewById(R.id.page_title_right_icon);
//        iv.setImageResource(R.drawable.ic_settings);
//        mTitleBar.setOnRightClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
//        mInputLayout = mChatLayout.getInputLayout();
//        messageHandler = mInputLayout.getMessageHandler();
//        mCustomMessageBean = getCustomMessageBean();
//        mInputLayout.setCustomMessageBean(mCustomMessageBean);

    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_chat_x;
    }

    @Override
    public ChatPresenter setPresenter() {
        return new ChatPresenter(this);
    }


    private void getMsgHistory(V2TIMMessage lastMsg) {

    }


    @Override
    public void onClick(View v) {

    }
//    private void selectPicture() {
//        PictureSelector.create(this)
//                .openGallery(PictureMimeType.ofImage())
//                .imageEngine(GlideEngine.createGlideEngine())
//                .isWeChatStyle(true).maxSelectNum(1)
//                .isEnableCrop(false)
//                .withAspectRatio(1, 1)
//                .isCompress(true)
////                .isCompressToSpecified(true)
//                .forResult(new OnResultCallbackListener<LocalMedia>() {
//                    @Override
//                    public void onResult(List<LocalMedia> result) {
//                        LocalMedia media = result.get(0);
//                        String compressPath = media.getCompressPath();
//                        aliUploadUtils.upLoadFile(compressPath, new FileUploadCallback() {
//                            @Override
//                            public void onFailure(String str) {
//
//                            }
//
//                            @Override
//                            public void onSuccess(Object paramRequestString, String filePath) {
//                                CustomMessageBean.DataBean.PictureBean pictureBean = new CustomMessageBean.DataBean.PictureBean();
//                                pictureBean.width = media.getWidth();
//                                pictureBean.height = media.getHeight();
//                                pictureBean.url = filePath;
//                                CustomMessageBean customMessageBean = new CustomMessageBean();
//                                customMessageBean.data.picture = pictureBean;
//                                customMessageBean.data.msgType = "picture";
//                                customMessageBean.data.content="[图片]";
//                                customMessageBean.data.time = System.currentTimeMillis();
//                                String json = gson.toJson(customMessageBean, (new TypeToken<CustomMessageBean>() {
//                                }).getType());
//                                if (messageHandler != null) {
//                                    messageHandler.sendMessage(MessageInfoUtil.buildCustomMessage(json));
//                                }
//
//                            }
//
//                            @Override
//                            public void onProgress(PutObjectRequest request, long currentSize, long totalSize) {
//
//                            }
//                        });
//                    }
//
//                    public void onCancel() {}
//
//    }); }

    @Override
    public void loadSTSCert(STSCertBean.DatasBean data) {
//        keyID = data.getAccessKeyId();
//        keySecret = data.getAccessKeySecret();
//        securityToken = data.getSecurityToken();
//        aliUploadUtils = AliUploadUtils.getInstance(keyID, keySecret, securityToken);
    }

    @Override
    public void liveApplySuccess() {

    }

    @Override
    public void hasBlacked(boolean hasBlacked) {

    }

    @Override
    public void showAccount(AccountBean.DatasBean data) {

    }

    @Override
    public void showAnchorData(AnchorDetailBean.DatasBean data) {

    }

    @Override
    public void hasFollowed(boolean hasFollowed) {

    }

    @Override
    public void setFollowedSuccess() {

    }

    @Override
    public void setFollowedFailed() {

    }
}
